#ifndef NODEITEMBASE_H
#define NODEITEMBASE_H

#include<QGraphicsItem>
#include<QGraphicsTextItem>
#include<QtGui>
#include<QGraphicsProxyWidget>
#include<QList>
#include<QDataStream>

#include"node_socket.h"
#include"node_content_base.h"
#include"item_enum.h"
#include"opengl/node_opengl_test.h"

class NodeItemBase : public QGraphicsItem
{
public:
    NodeItemBase();
    NodeItemBase(QString title);
    NodeItemBase(const NodeItemBase &nodeItem);
    ~NodeItemBase();
    void operator=(const NodeItemBase &nodeItem);

    int type() const override {return Type_NodeItem;}

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    QRectF boundingRect()const override;
//    bool contains(const QPointF &point) const override;
    void SetTitle(QString title);

    double virtual GetData();
    void virtual SetData(QString str);
    NumberData virtual GetNumberData();
    void virtual SetNumberData(NumberData data);

public:
    QString title;
    QColor *title_color;
    QGraphicsTextItem *text;
    QGraphicsProxyWidget *proxyContent;  //嵌入的widget
    //NodeContentNumber *content;

public:
    float width = 180; // 节点大小
    float title_height = 24;
    float height = 100;
    float edge_size = 10.0;


};


class NodeItemNumber : public NodeItemBase
{
public:
    NodeItemNumber();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeItemNumber;}

public:
    NodeContentNumber *content;
};


class NodeItemOutput : public NodeItemBase
{
public:
    NodeItemOutput();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeItemOutput;}

public:
    NodeContentOutput *content;
};

class NodeItemAdd :public NodeItemBase
{
public:
    NodeItemAdd();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeItemAdd;}

public:
    NodeContentAdd *content;

};

class NodeItemSub :public NodeItemBase
{
public:
    NodeItemSub();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeItemSub;}

public:
    NodeContentSub *content;

};

class NodeItemMul :public NodeItemBase
{
public:
    NodeItemMul();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeItemMul;}

public:
    NodeContentMul *content;

};

class NodeItemDiv :public NodeItemBase
{
public:
    NodeItemDiv();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeItemDiv;}

public:
    NodeContentDiv *content;

};

class NodeGraphicsShow : public NodeItemBase
{
public:
    NodeGraphicsShow();
    double GetData() override;
    void SetData(QString str) override;

    NumberData GetNumberData() override;
    void SetNumberData(NumberData data) override;
    int type() const override {return Type_NodeGraphics;}

public:
    NodeContentBase *content;
};

#endif // NODEITEMBASE_H
